package com.example.webbasic.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import com.example.webbasic.interceptor.MyInterceptor1;
import com.example.webbasic.interceptor.MyInterceptor2;

@Configuration
public class MyWebAppConfigurer implements WebMvcConfigurer {

	/**
	 * 拦截器配置
	 * 注意，拦截器不处理 Servlet 中的请求！
	 */
	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		WebMvcConfigurer.super.addInterceptors(registry);
		
		// 调整顺序进行测试：结果会不同
		registry.addInterceptor(new MyInterceptor2()).addPathPatterns("/**");
		registry.addInterceptor(new MyInterceptor1()).addPathPatterns("/**");
	}

}
